import request from "@/utils/request";
import { rootsUrl } from "../utils";
import { getToken } from "@/utils/auth";
import Qs from "qs";

/**
 * 获取学习指南标签
 */
export const getLearningTag = () => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/tutorial/getTutorialTypeList.shtml`,
    method: "get"
  });
};

/**
 * 获取学习指南列表
 * @param {Number} pageIndex
 * @param {Number} tag 学习资源标签类型
 */
export const getLearningGuideList = (pageIndex, tag) => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/tutorial/getTutorialList.shtml`,
    method: "get",
    params: {
      pageIndex,
      tag,
      pageSize: 10
    }
  });
};

/**
 * 获取学习指南详情
 * @param {Number} id
 */
export const getLearningGuideDetail = id => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/tutorial/getTutorialDetails.shtml`,
    method: "get",
    params: {
      id
    }
  });
};

/**
 * 获取学习资源列表
 * @param {Number} pageIndex 页数
 * @param {*} tag
 */
export const getLearningResourceList = (pageIndex, tag) => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/learnResource/getLearnResourceList.shtml`,
    method: "get",
    params: {
      pageIndex,
      tag,
      pageSize: 10
    }
  });
};

/**
 * 获取学习资源详情
 * @param {Number} id
 */
export const getLearningResourceDetail = id => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/learnResource/getLearnResourceDetails.shtml`,
    method: "get",
    params: {
      id
    }
  });
};

/**
 * 获取教育政策列表
 * @param {Number} pageIndex 页数
 * @param {*} tag
 */
export const getPolicyList = (pageIndex, tag) => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/polipy/getPolipyList.shtml`,
    method: "get",
    params: {
      pageIndex,
      tag,
      pageSize: 10
    }
  });
};

/**
 * 获取教育政策详情
 * @param {Number} id
 */
export const getPolicyDetail = id => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/polipy/getPolipyDetails.shtml`,
    method: "get",
    params: {
      id
    }
  });
};

/**
 * 验证下载码，并获取附件下载路径
 * @param {*} id 文章ID
 * @param {*} code 下载码
 */
export const postDownloadCode = (id, code) => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/learnResource/downLoadLearnResource.shtml`,
    method: "get",
    params: {
      id,
      code
    }
  });
};

/**
 * 获取资讯列表
 * @param {*} pageIndex
 * @param {*} pageSize
 */
export const getlearningNews = (pageIndex, pageSize) => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/actInfo/getActInfoList.shtml`,
    method: "get",
    params: {
      pageIndex,
      pageSize
    }
  });
};

/**
 * 获取资讯详情
 * @param {*} id
 */
export const getlearningDetail = id => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/actInfo/getActInfoDetails.shtml`,
    method: "get",
    params: {
      id
    }
  });
};
